<?php

/**
 * Created by PhpStorm.
 * User: 曾剑杰
 * Email: kevin0217@126.com
 * @ Date: 2024-09-14
 * Time: 9:34
 */

namespace app\api\controller;

use app\common\controller\ApiBase;
use app\common\model\Banner as BannerModel;

class Banner extends ApiBase
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function list()
    {
        $this->checkRequestParam(\app\common\validate\Banner::class);
        $param = $this->request->param();

        $where = [
            'category_id' => $param['category_id'],
            'status' => 'normal'
        ];


        $banner = BannerModel::where($where)
            ->paginate($this->getPaginate());

        $data = $banner->items();
        $count = $banner->total();


        $this->success('成功', ['list' => $data, 'count' => $count]);
    }
}
